using System;
using System.Drawing;
using System.Windows.Forms;

using Leadtools.MedicalViewer;

namespace Main3DDemo
{
   public partial class LayoutOptions : Form
   {
      MedicalViewer _viewer;
      MainPanel _panel;

      public LayoutOptions()
      {
         InitializeComponent();
      }

      public LayoutOptions(MedicalViewer viewer, MainPanel panel)
      {
         _viewer = viewer;
         _panel = panel;

         InitializeComponent();

         _txtRows.Value = _viewer.Rows;
         _txtColumns.Value = _viewer.Columns;
         _interpolateAlwaysImage.Checked = _panel.AlwaysInterpolate;
      }

      private void _btnOK_Click(object sender, EventArgs e)
      {
         if (_viewer.Rows != _txtRows.Value)
            _viewer.Rows = _txtRows.Value;

         if (_viewer.Columns != _txtColumns.Value)
            _viewer.Columns = _txtColumns.Value;

         _panel.AlwaysInterpolate = _interpolateAlwaysImage.Checked;

         int counter;
         MedicalViewerCell cell;
         for (counter = 0; counter < _viewer.Cells.Count; counter++)
         {
            if (_viewer.Cells[counter] is MedicalViewerCell)
            {
               cell = ((MedicalViewerCell)_viewer.Cells[counter]);
               cell.AlwaysInterpolate = _interpolateAlwaysImage.Checked;
            }
         }
      }

      private void _btnApply_Click(object sender, EventArgs e)
      {
         _btnOK_Click(sender, e);
      }
   }
}
